Completed
Push — phpunit ( 7f2080...75f541 )
by Marcos
14:28 queued 10:45
created

PassmanImporter.zohoCsv.readFile   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 27

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 27
rs 8.8571
1
// Importers should always start with this
2
var PassmanImporter = PassmanImporter || {};
1 ignored issue
show
Bug introduced by
The variable PassmanImporter seems to be never initialized.
Loading history...
3
4
(function(window, $, PassmanImporter) {
5
	'use strict';
6
7
	// Define the importer
8
	PassmanImporter.zohoCsv = {
9
		info: {
10
			name: 'ZOHO csv',
11
			id: 'zohoCsv',
12
			description: 'Create an csv export. Go to Tools ->  Export secrets -> Select "General CSV" and click "Export Secrets"'
13
		}
14
	};
15
16
	PassmanImporter.zohoCsv.readFile = function (file_data) {
17
		return new C_Promise(function(){
0 ignored issues
show
Bug introduced by
The variable C_Promise seems to be never declared. If this is a global, consider adding a /** global: C_Promise */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
18
			var parsed_csv = PassmanImporter.readCsv(file_data, false);
19
			var credential_list = [];
20
			for (var i = 0; i < parsed_csv.length; i++) {
21
				var row = parsed_csv[i];
22
				var _credential = PassmanImporter.newCredential();
23
				_credential.label = row[0];
24
				_credential.username = row[3];
25
				_credential.password = row[4];
26
				_credential.url = row[1];
27
				_credential.description = row[2];
28
				if(_credential.label){
29
					credential_list.push(_credential);
30
				}
31
32
				var progress = {
33
					percent: i/parsed_csv.length*100,
34
					loaded: i,
35
					total: parsed_csv.length
36
				};
37
38
				this.call_progress(progress);
39
			}
40
			this.call_then(credential_list);
41
		})
0 ignored issues
show
Coding Style introduced by
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
42
	};
43
})(window, $, PassmanImporter);
44